<?php

/*用户设置表类*/

class configModel extends Model
{

	private $tb='user_set';

	
	/*获取用户所有设置*/
	public function getall($uid)
	{
		$sql='select * from '.$this->tb.' where uid='.$uid;
		return $this->db->getAll($sql);
	}

	/*获取用户单个设置*/
	public function get($uid,$name)
	{
		$sql='select '.$name.' from '.$this->tb.' where uid='.$uid;
		return $this->db->getOne($sql);
	}

	/*设置用户单个设置*/
	public function set($uid,$name,$val)
	{
		$sql="update $this->tb set $name=$val where uid=$uid";
		return $this->db->set_query($sql);
	}

	/*获取用户N个设置*/
	public function gets($uid,$arr)
	{
		$sql='select '.implode(',', array_values($arr)).' from '.$this->tb.' where uid='.$uid;
		return $this->db->getRow($sql);
	}





	//批量设置设置
	/*
	参数 
	array(
		设置名=>设置值
	);
	将数组内所有设置名=>设置值
	*/
	public function setpart($arr,$uid)
	{
		
		return $this->db->updatebyattr($this->tb,$arr,'uid',$uid);
	}


}